home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / exec / RCS / _ExecArgs.c,v next >
Encoding:
Text File  |  1988-07-29  |  2.3 KB  |  111 lines

  1. head     1.2;
  2. access   ;
  3. symbols  ;
  4. locks    ; strict;
  5. comment  @ * @;
  6.  
  7.  
  8. 1.2
  9. date     88.07.28.17.49.57;  author ouster;  state Exp;
  10. branches ;
  11. next     1.1;
  12.  
  13. 1.1
  14. date     88.06.19.16.55.54;  author ouster;  state Exp;
  15. branches ;
  16. next     ;
  17.  
  18.  
  19. desc
  20. @@
  21.  
  22.  
  23. 1.2
  24. log
  25. @How'd this ever work?  Wasn't returning a value.
  26. @
  27. text
  28. @/* 
  29.  * _ExecArgs.c --
  30.  *
  31.  *    Source code for the _ExecArgs library utility procedure.
  32.  *
  33.  * Copyright 1988 Regents of the University of California
  34.  * Permission to use, copy, modify, and distribute this
  35.  * software and its documentation for any purpose and without
  36.  * fee is hereby granted, provided that the above copyright
  37.  * notice appear in all copies.  The University of California
  38.  * makes no representations about the suitability of this
  39.  * software for any purpose.  It is provided "as is" without
  40.  * express or implied warranty.
  41.  */
  42.  
  43. #ifndef lint
  44. static char rcsid[] = "$Header: _ExecArgs.c,v 1.1 88/06/19 16:55:54 ouster Exp $ SPRITE (Berkeley)";
  45. #endif not lint
  46.  
  47. #include <varargs.h>
  48.  
  49. /*
  50.  * Library imports:
  51.  */
  52.  
  53. extern char *malloc();
  54.  
  55.  
  56. /*
  57.  *----------------------------------------------------------------------
  58.  *
  59.  * _ExecArgs --
  60.  *
  61.  *    Collect an argument list, as passed to execl or execle, into
  62.  *    a dynamically-allocated array.
  63.  *
  64.  * Results:
  65.  *    The return value is a pointer to an array, dynamically
  66.  *    allocated, that contains the argv values pointed to by
  67.  *    args.  Args is updated so that the next va_arg will return
  68.  *    the argument just after the terminating 0 in the argv
  69.  *    list.  It is the caller's responsibility to free the
  70.  *    return value if that is desired.
  71.  *
  72.  * Side effects:
  73.  *    None.
  74.  *
  75.  *----------------------------------------------------------------------
  76.  */
  77.  
  78. char **
  79. _ExecArgs(args)
  80.     va_list *args;        /* Pointer to arguments containing a variable-
  81.                  * length collection of argv values, with
  82.                  * a zero value to terminate. */
  83. {
  84.     va_list arg2;
  85.     int count, i;
  86.     register char **array;
  87.  
  88.     arg2 = *args;
  89.     for (count = 1; va_arg(arg2, char *) != 0; count++) {
  90.     /* Null loop body. */
  91.     }
  92.     array = (char **) malloc((unsigned) (count * sizeof(char *)));
  93.     for (i = 0; i < count; i++) {
  94.     array[i] = va_arg(*args, char *);
  95.     }
  96.     return array;
  97. }
  98. @
  99.  
  100.  
  101. 1.1
  102. log
  103. @Initial revision
  104. @
  105. text
  106. @d17 1
  107. a17 1
  108. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  109. d69 1
  110. @
  111.